package com.yystar.support.base.typehandler;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

import com.yystar.support.base.domain.Stake;

public class StakeTypeHandler extends BaseTypeHandler {

	@Override
	public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
		 ps.setDouble(i, ((Stake) parameter).getAmount());
		
	}

	@Override
	public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
		return new Stake(rs.getDouble(columnName));
	}

	@Override
	public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
		return new Stake(cs.getDouble(columnIndex));
	}

}
